package com.xingdata.jjxc.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

/**
 * 获取视频缩略图
 * @author Administrator
 *
 */
public class BitmapTask implements Task {
	private final String TAG = "BitmapTask";
	private String url;
	// private LruCache<String, Bitmap> bitMap;
	private Handler handler;
	private boolean isCancel=true;
	private Float fMulriple;
	private Context mContext;

	public BitmapTask(Context context,String url, Handler handler, Float fMulriple) {
		this.url = url;
		this.handler = handler;
		this.fMulriple=fMulriple;
		this.mContext=context;
	}

	@Override
	public void runTask() {
		
		Bitmap bitmap = SDCardTools.getSDImage(url, 1.8f);
		if (bitmap==null) {
			bitmap=ImageTools.getUrlImage(mContext, url, true, fMulriple);
		}
		BitmapCache.put(url, bitmap);
		Message message = new Message();
		message.what = MessageCode.MessageCode_RefreshControl;
		handler.sendMessage(message);

	}

	@Override
	public void cacelTask() {
		isCancel=false;
	}

	@Override
	public boolean isCancel() {
		return isCancel;
	}

}
